import request, { download } from '@/utils/request'

/**
 * 字典类型表 Api
 *
 * @author EasyAdmin ( 1073602@qq.com )
 * @date 2025-08-26
 */
export default {

  /**
   * 分页查询
   * @param query 查询参数
   */
  page: (query: any) => {
    return request.get('/admin/system/dict/page', { params: query })
  },

  /**
   * 查询列表
   * @param query 查询参数
   */
  list: (query: any) => {
    return request.get('/admin/system/dict/list', { params: query })
  },

  /**
   * 查询详细
   * @param query 查询参数
   */
  getById: (id: string) => {
    return request.get(`/admin/system/dict/${id}`)
  },

  /**
   * 新增
   * @param data 新增数据
   */
  add: (data: any) => {
    return request.post('/admin/system/dict', data)
  },

  /**
   * 修改
   * @param data 修改数据
   */
  update: (data: any) => {
    return request.put('/admin/system/dict', data)
  },

  /**
   * 删除
   * @param ids 删除Ids
   */
  delete: (ids: any) => {
    return request.delete(`/admin/system/dict/${ids}`)
  },

  /**
   * 导出Excel
   * @param filename Excel文件名称
   * @param query 查询参数
   */
  download: (query: any, filename: string) => {
    download('/admin/system/dict/export', { ...query }, `${filename}.xlsx`, {})
  },

  // 刷新字典缓存
  refreshCache: () => {
    return request.delete('/admin/system/dict/refreshCache')
  },

  // 获取字典选择框列表
  optionselect: () => {
    return request.get('/admin/system/dict/optionselect')
  },

}